package com.iknow.activity;

import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.widget.Button;
import com.iknow.IKnow;
import com.iknow.IKnowApiV4;
import com.iknow.app.IKnowSystemConfig;
import com.iknow.data.QingBo;
import com.iknow.http.HttpException;
import com.iknow.task.CommonTask.QingboTask;
import com.iknow.task.TaskParams;
import com.iknow.util.Loger;
import com.iknow.util.StringUtil;
import com.iknow.view.widget.PullToRefreshListView;
import java.util.List;
import java.util.List<Lcom.iknow.data.QingBo;>;
import org.jivesoftware.smack.util.StringUtils;

public class FollowActivity extends QingboWithNoHeaderActivity
{
  List<QingBo> doGetLocolData()
  {
    Object localObject2;
    String str = IKnow.mSystemConfig.getString("account_username");
    try
    {
      if (StringUtil.isEmpty(str))
      {
        localObject2 = IKnow.mApi.getQingboListByRosterIDLocal("IM_Content", 0, 20);
      }
      else
      {
        List localList = IKnow.mApi.getQingboListByFollowLocal(StringUtils.parseName(str), 0, 20);
        localObject2 = localList;
      }
    }
    catch (HttpException localHttpException)
    {
      Loger.e(this.TAG, localHttpException.getMessage());
      localHttpException.printStackTrace();
      localObject1 = null;
      break label78:
    }
    Object localObject1 = localObject2;
    label78: return ((List<QingBo>)localObject1);
  }

  void doNeedMore()
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING))
      return;
    this.mGetMoreButton.setText("正在载入数据...");
    this.mTask = new CommonTask.QingboTask();
    this.mTask.setListener(this.mGetMoreListener);
    this.mTask.setAdapter(this.mAdapter);
    TaskParams localTaskParams = new TaskParams();
    String str = IKnow.mSystemConfig.getString("account_username");
    if (!(StringUtil.isEmpty(str)))
      localTaskParams.put("user_id", StringUtils.parseName(str));
    while (true)
    {
      while (true)
      {
        localTaskParams.put("offset", Integer.valueOf(getCurrentListLength()));
        localTaskParams.put("length", Integer.valueOf(20));
        CommonTask.QingboTask localQingboTask = this.mTask;
        TaskParams[] arrayOfTaskParams = new TaskParams[1];
        arrayOfTaskParams[0] = localTaskParams;
        localQingboTask.execute(arrayOfTaskParams);
      }
      localTaskParams.put("create_user", "IM_Content");
    }
  }

  void getServerData()
  {
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.PAGE_TYPE = 1;
    this.TAG = "FollowActivity";
    getLocolData();
  }

  void refreshData()
  {
    if ((this.mTask != null) && (this.mTask.getStatus() == AsyncTask.Status.RUNNING))
      return;
    String str1 = IKnow.mSystemConfig.getString(this.TAG);
    if (!(StringUtil.isEmpty(str1)))
      this.mListView.setLastUpdated("更新于" + str1);
    this.mTask = new CommonTask.QingboTask();
    this.mTask.setListener(this.mTaskListener);
    this.mTask.setAdapter(this.mAdapter);
    TaskParams localTaskParams = new TaskParams();
    String str2 = IKnow.mSystemConfig.getString("account_username");
    if (!(StringUtil.isEmpty(str2)))
      localTaskParams.put("user_id", StringUtils.parseName(str2));
    while (true)
    {
      while (true)
      {
        localTaskParams.put("offset", Integer.valueOf(0));
        localTaskParams.put("length", Integer.valueOf(20));
        CommonTask.QingboTask localQingboTask = this.mTask;
        TaskParams[] arrayOfTaskParams = new TaskParams[1];
        arrayOfTaskParams[0] = localTaskParams;
        localQingboTask.execute(arrayOfTaskParams);
      }
      localTaskParams.put("create_user", "IM_Content");
    }
  }
}